home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-05-01 | 5.8 KB | 164 lines | [TEXT/PJMM] |
- unit ICSpecificOverride;
-
- (* Internet Config Specific Overide Component *)
-
- (* Routine names have an ICSO prefix for Internet Config Specific Override. *)
-
- (* To create an IC override component you need to make a copy of this *)
- (* file and fill in the blanks. This is an N stage process: *)
-
- (* 1. Make a copy of this file. *)
- (* 2. Change kOurComponentManufacturer to your manufacturer code. *)
- (* 3. Add any shared globals to the sharedGlobals record. *)
- (* 4. If you have shared globals then init them in ICSOInitShared. *)
- (* 5. If the shared globals need cleaning up then clean them ICSOCleanShared. *)
- (* 6. Add any instance specific globals to globalsRecord. *)
- (* 7. If you have globals then init them in ICSOInitGlobals. *)
- (* 8. If the globals need cleaning up then clean them ICSOCleanGlobals. *)
- (* 9. If you want to add a completely new routine or remove support *)
- (* for one of the built in routines then modify ICSOCanDo accordingly. *)
- (* 10. Modify ICSOWhatToOverride to return the correct ProcPtr for each *)
- (* routine that you override or add. *)
- (* 11. Write each routine. If you want the component to continue calling *)
- (* through to the captured component for this routine then have your *)
- (* routine return delegateThisCallErr. *)
- (* 12. Smirk at the wonders of Component Manager. *)
- (* 13. Looking inside ICGenericOverride and frown at the wonders of Component Manager. *)
-
- (* Share and Enjoy. *)
-
- (* Quinn *)
- (* 12 Feb 1995 *)
-
- interface
-
- uses
- Components;
-
- const
- kOurComponentManufacturer = 'ICRo';
- (* You must set this up appropriately. Things will not be good otherwise. *)
-
- delegateThisCallErr = $81234568;
- (* Return this from a component routine if you want the generic override *)
- (* component to pass this call through to the captured component. *)
-
- type
- sharedGlobals = record
- delegate: Component;
- (* add your own shared globals here *)
- end;
- sharedGlobalsPtr = ^sharedGlobals;
-
- globalsRecord = record
- self: ComponentInstance;
- target: ComponentInstance;
- delegate: ComponentInstance;
- shared: sharedGlobalsPtr;
- (* add your own component specific globals here*)
- end;
- globalsPtr = ^globalsRecord;
- globalsHandle = ^globalsPtr;
-
- (* Except when otherwise noted the globals handle is *)
- (* locked when any of these routines are called. *)
-
- function ICSOInitShared (globals: globalsHandle): ComponentResult;
- (* This routine is called to init the shared globals. *)
- (* If you return an error then you should make sure your part of *)
- (* the shared globals are 'clean'. *)
-
- function ICSOCleanShared (globals: globalsHandle): ComponentResult;
- (* This routine is called to clean the shared globals. *)
- (* WARNING: This will never been called if you're using an old version *)
- (* of the Component Manager. Workaround: If your specifics only bleeds *)
- (* small amounts of memory then don't worry. If your specifics bleeds a *)
- (* lot of memory or other resources (such as open files) then refuse to *)
- (* install with older Component Managers (I think it was fixed in v2 of the *)
- (* manager. *)
-
- function ICSOInitGlobals (globals: globalsHandle): ComponentResult;
- (* This routine inits the override specific fields of the component *)
- (* specific globals. If it returns an error then the globals must be 'clean'. *)
-
- function ICSOCleanGlobals (globals: globalsHandle): ComponentResult;
- (* This routine cleans up the component specific globals, disposing any *)
- (* pointers and otherwise releasing any allocated resources. *)
-
- function ICSOCanDo (globals: globalsHandle; selector: integer): ComponentResult;
- (* This routine is called in response to a component can do request. *)
- (* You should set component result to: *)
- (* -1 if you definitely want to say that the component can't do this *)
- (* 0 if you definitely want to say that the component can do this *)
- (* 1 if you want to let the target decide *)
- (* WARNING: These constants are quite different from the constants *)
- (* used by a standard Component Manager CanDo request. *)
-
- function ICSOWhatToOverride (globals: globalsHandle; selector: integer): ProcPtr;
- (* Return nil if you do not want to override this what. *)
- (* Return a pointer to a procedure with the appropriate signature *)
- (* if you do. *)
- (* WARNING: globals will not necessarily be locked and may be nil!!! *)
-
- implementation
-
- uses
- ICTypes, ICCAPI, ICComponentSelectors;
-
- function ICSOInitShared (globals: globalsHandle): ComponentResult;
- begin
- ICSOInitShared := noErr;
- end; (* ICSOInitShared *)
-
- function ICSOCleanShared (globals: globalsHandle): ComponentResult;
- begin
- ICSOCleanShared := noErr;
- end; (* ICSOCleanShared *)
-
- function ICSOInitGlobals (globals: globalsHandle): ComponentResult;
- begin
- ICSOInitGlobals := noErr;
- end; (* ICSOInitGlobals *)
-
- function ICSOCleanGlobals (globals: globalsHandle): ComponentResult;
- begin
- ICSOCleanGlobals := noErr;
- end; (* ICSOCleanGlobals *)
-
- function ICSOCanDo (globals: globalsHandle; selector: integer): ComponentResult;
- begin
- ICSOCanDo := delegateThisCallErr;
- end; (* ICSOCanDo *)
-
- function RSCGetPref (globals: globalsHandle; key: Str255; var attr: ICAttr; buf: Ptr; var size: longint): ICError;
- var
- err: ICError;
- begin
- err := ICCGetPref(globals^^.delegate, key, attr, buf, size);
- bset(attr, ICattr_locked_bit);
- RSCGetPref := err;
- end; (* RSCGetPref *)
-
- function RSCSetPref (globals: globalsHandle; key: Str255; var attr: ICAttr; buf: Ptr; var size: longint): ICError;
- begin
- RSCSetPref := icPermErr;
- end; (* RSCSetPref *)
-
- function ICSOWhatToOverride (globals: globalsHandle; selector: integer): ProcPtr;
- var
- proc: ProcPtr;
- begin
- proc := nil;
- case selector of
- kICCGetPref:
- proc := @RSCGetPref;
- kICCSetPref:
- proc := @RSCSetPref;
- otherwise
- ;
- end; (* case *)
- ICSOWhatToOverride := proc;
- end; (* ICSOWhatToOverride *)
-
- end. (* ICSpecificOverride *)
-